//
//  AmountHeaderView.m
//  DebugDemo
//
//  Created by XFB on 2018/11/28.
//  Copyright © 2018年 ZhouCheng. All rights reserved.
//

#import "AmountHeaderView.h"
#import "AmountModel.h"

@interface AmountHeaderView ()

@property (nonatomic, weak) UILabel *timeLabel;
@property (nonatomic, weak) UILabel *amountLabel;

@end

@implementation AmountHeaderView

+ (instancetype)amountHeaderViewViewWithTableView:(UITableView *)tableView
{
    static NSString *headID = @"AmountHeaderView";
    AmountHeaderView *headerView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:headID];
    if (headerView == nil) {
        headerView = [[self alloc] initWithReuseIdentifier:headID];
    }
    return headerView;
}

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    self.contentView.backgroundColor = RGB(220, 220, 220);
    
    UILabel *timeLabel = [[UILabel alloc] init];
    timeLabel.font = [UIFont systemFontOfSize:16];
    timeLabel.textColor = UIColorFromRGB(0x333333);
    [self.contentView addSubview:timeLabel];
    self.timeLabel = timeLabel;
    
    UILabel *amountLabel = [[UILabel alloc] init];
    amountLabel.textAlignment = NSTextAlignmentRight;
    amountLabel.font = [UIFont systemFontOfSize:16];
    amountLabel.textColor = UIColorFromRGB(0x333333);
    [self.contentView addSubview:amountLabel];
    self.amountLabel = amountLabel;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.timeLabel.frame = CGRectMake(20, 0, 120, 60);
    self.amountLabel.frame = CGRectMake(ScreenW-200, 0, 180, 60);
}

- (void)setAmountModel:(AmountModel *)amountModel
{
    _amountModel = amountModel;
    self.timeLabel.text = amountModel.time;
    self.amountLabel.text = [NSString stringWithFormat:@"激活收入%ld元", amountModel.amount];
}


@end
